#!/usr/bin/env python2
#-*- coding: utf-8 -*-

import ConfigParser
import os
import uuid
import inspect 
from subprocess import Popen, PIPE
from Umpweb.common import utils

ump_home = utils.home

cp = ConfigParser.ConfigParser()
oemfile = '%s/etc/ump/oem/oem.conf'%ump_home
cp.read(oemfile)

def path():
    pass
path = inspect.getabsfile(path)
path = '/'.join(path.split('/')[0:-2])
path = path + '/static/img/'

oem = False
if not os.path.isfile(oemfile):
    oem = True
name = ''
logo = '' 
logo_path = '/dev/null' 
try:
    oem = cp.get('main', 'status') == 'on'
    if cp.get('main', 'status').lower() == 'h3c':
        oem = 'h3c'
    name = cp.get('main','system-name') 
    logo_path = cp.get('main','logo-path') 
    logo = logo_path.split('/')[-1]
except Exception,e:
    pass

try:
    os.system('cp %s %s 2>/dev/null'%(logo_path,path))
    os.system('cp %s %s 2>/dev/null'%(logo_path,'%s/etc/ump/oem'%ump_home))
    os.system('cp %s %s 2>/dev/null'%('%s/etc/ump/oem/'%ump_home + logo,'%s/ump/Ump/static/img'%ump_home))
except Exception,e:
    pass


